package ClassificationAlgorithm;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import FeatureEnrichment.FeatureEnrichment;
import Global.ParametersClass;

public class RelRasCoParametres extends ParametersClass {

	public int maxIteration;
	public float maxMargin;
	public float selectionThreshold;
	public int currentFeatureSize;
	public int currentClassifierSize;
	public int multiplyClassifierSize;
	
	public List<Integer> numberOfFeature;
	public List<Integer> numberOfClassifier;
	
	public RelRasCoParametres() {
		this.numberOfClassifier = new ArrayList<Integer> ();
		this.numberOfFeature =  new ArrayList<Integer> ();
	}
	
	public String featureEnrichmentMethod;
	public FeatureEnrichment enrichment;
	
	@Override
	public void readParameters(String fileName) {
	
		File file = new File(fileName);
	    FileInputStream fileInputStream = null;
	    BufferedInputStream bufferedInputStream = null;
	    DataInputStream dataInputStream = null;
	    BufferedReader bufReader = null;
	
	    
	    
	    try {

	    	
	      fileInputStream = new FileInputStream(file);
	      // Here BufferedInputStream is added for fast reading.
	      bufferedInputStream = new BufferedInputStream(fileInputStream);
	      dataInputStream = new DataInputStream(bufferedInputStream);
	      bufReader =  new BufferedReader(new InputStreamReader(dataInputStream));

	      // dis.available() returns 0 if the file does not have more lines.
	      
	      String strLine;
	      String[] words;
	      	
	      while (dataInputStream.available() != 0) {

	    		/*
	    		Name RelRasCO
	    		Classifier GenericWekaClassifier
	    		

	    		 */
	    	  // Sampling Type is rea
	    	  this.classifierName = bufReader.readLine();
	    	  this.localClassifierName = bufReader.readLine();
	    	  
	    	  // M parameters
	    	  strLine = bufReader.readLine();
	    	  words = strLine.split(" ");
	    	  
	    	  //M 25 50
	    	  for(int i=1; i<words.length; i++)
	    	  {
	    		  this.numberOfFeature.add(Integer.parseInt(words[i]));
	    	  }
	    	  
	    	  strLine = bufReader.readLine();
	    	  words = strLine.split(" ");

	    	  //K 5 10 25
	    	  for(int i=1; i<words.length; i++)
	    	  {
	    		  this.numberOfClassifier.add(Integer.parseInt(words[i]));
	    	  }
    		   
	    	  strLine = bufReader.readLine();
	    	  words = strLine.split(" ");
	    	  this.maxMargin = Float.parseFloat(words[1]);
	    	  
	    	  strLine = bufReader.readLine();
	    	  words = strLine.split(" ");
	    	  this.maxIteration = Integer.parseInt(words[1]);
	    	  
	    	  strLine = bufReader.readLine();
	    	  words = strLine.split(" ");
	    	  this.selectionThreshold = Float.parseFloat(words[1]);

	    	  strLine = bufReader.readLine();
	    	  words = strLine.split(" ");
	    	  this.multiplyClassifierSize = Integer.parseInt(words[1]);
	    	  	    	  
	      }
	      // dispose all the resources after using them.
	      fileInputStream.close();
	      bufferedInputStream.close();
	      dataInputStream.close();

	    } catch (FileNotFoundException e) {
	      e.printStackTrace();
	    } catch (IOException e) {
	      e.printStackTrace();
	    }	
	}
}
